{% load i18n %}
{% load humanize %}
<ul class="tree" data-level="{{ level }}">
    {% for premise in premises %}
        <li id="premise-{{ premise.id }}" class="tree-branch">
            <div class="connector branch-connector{% if premises|length < 2 %} branch-single{% endif %}"></div>
            {% include "premises/premise.html" %}
            {% if premise.children %}
            {% if level == 1 and premises|length > 5 %}
                <div data-load-partial="?partial={{ premise.id }}&level={{ level|add:1 }}"></div>
            {% else %}
                {% with template_name="premises/tree.html" premises=premise.children level=level|add:1 %}
                    {% include template_name %}
                {% endwith %}
            {% endif %}
            <div class="connector child-connector"></div>
            {% endif %}
        </li>
    {% endfor %}
    {% if premises %}
        <li class="connector tree-connector"></li>
        <li class="collapsible-preview">{{ premises|length|add:-1 }} {% trans "branch" %}</li>
        <li class="collapse-button">‒</li>
    {% endif %}
</ul>
